home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / text / View.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  5.2 KB  |  215 lines

  1. package javax.swing.text;
  2.  
  3. import java.awt.Container;
  4. import java.awt.Graphics;
  5. import java.awt.Rectangle;
  6. import java.awt.Shape;
  7. import javax.swing.SwingConstants;
  8. import javax.swing.event.DocumentEvent;
  9. import javax.swing.text.Position.Bias;
  10.  
  11. public abstract class View implements SwingConstants {
  12.    public static final int BadBreakWeight = 0;
  13.    public static final int GoodBreakWeight = 1000;
  14.    public static final int ExcellentBreakWeight = 2000;
  15.    public static final int ForcedBreakWeight = 3000;
  16.    public static final int X_AXIS = 0;
  17.    public static final int Y_AXIS = 1;
  18.    static final Position.Bias[] sharedBiasReturn = new Position.Bias[1];
  19.    private View parent;
  20.    private Element elem;
  21.  
  22.    public View(Element var1) {
  23.       this.elem = var1;
  24.    }
  25.  
  26.    public View breakView(int var1, int var2, float var3, float var4) {
  27.       return this;
  28.    }
  29.  
  30.    public void changedUpdate(DocumentEvent var1, Shape var2, ViewFactory var3) {
  31.    }
  32.  
  33.    public View createFragment(int var1, int var2) {
  34.       return this;
  35.    }
  36.  
  37.    public float getAlignment(int var1) {
  38.       return 0.5F;
  39.    }
  40.  
  41.    public AttributeSet getAttributes() {
  42.       return this.elem.getAttributes();
  43.    }
  44.  
  45.    public int getBreakWeight(int var1, float var2, float var3) {
  46.       return var3 > this.getPreferredSpan(var1) ? 1000 : 0;
  47.    }
  48.  
  49.    public Shape getChildAllocation(int var1, Shape var2) {
  50.       return null;
  51.    }
  52.  
  53.    public Container getContainer() {
  54.       View var1 = this.getParent();
  55.       return var1 != null ? var1.getContainer() : null;
  56.    }
  57.  
  58.    public Document getDocument() {
  59.       return this.elem.getDocument();
  60.    }
  61.  
  62.    public Element getElement() {
  63.       return this.elem;
  64.    }
  65.  
  66.    public int getEndOffset() {
  67.       return this.elem.getEndOffset();
  68.    }
  69.  
  70.    public float getMaximumSpan(int var1) {
  71.       int var2 = this.getResizeWeight(var1);
  72.       return var2 == 0 ? this.getPreferredSpan(var1) : (float)Integer.MAX_VALUE;
  73.    }
  74.  
  75.    public float getMinimumSpan(int var1) {
  76.       int var2 = this.getResizeWeight(var1);
  77.       return var2 == 0 ? this.getPreferredSpan(var1) : 0.0F;
  78.    }
  79.  
  80.    public int getNextVisualPositionFrom(int var1, Position.Bias var2, Shape var3, int var4, Position.Bias[] var5) throws BadLocationException {
  81.       var5[0] = Bias.Forward;
  82.       switch (var4) {
  83.          case 1:
  84.             JTextComponent var9 = (JTextComponent)this.getContainer();
  85.             Rectangle var10 = var9.modelToView(var1);
  86.             var1 = Utilities.getPositionAbove(var9, var1, var10.x);
  87.             break;
  88.          case 2:
  89.          case 4:
  90.          case 6:
  91.          default:
  92.             throw new IllegalArgumentException("Bad direction: " + var4);
  93.          case 3:
  94.             if (var1 == -1) {
  95.                var1 = this.getStartOffset();
  96.             } else {
  97.                var1 = Math.min(var1 + 1, this.getDocument().getLength());
  98.             }
  99.             break;
  100.          case 5:
  101.             JTextComponent var6 = (JTextComponent)this.getContainer();
  102.             Rectangle var7 = var6.modelToView(var1);
  103.             var1 = Utilities.getPositionBelow(var6, var1, var7.x);
  104.             break;
  105.          case 7:
  106.             if (var1 == -1) {
  107.                var1 = Math.max(0, this.getEndOffset() - 1);
  108.             } else {
  109.                var1 = Math.max(0, var1 - 1);
  110.             }
  111.       }
  112.  
  113.       return var1;
  114.    }
  115.  
  116.    public View getParent() {
  117.       return this.parent;
  118.    }
  119.  
  120.    public abstract float getPreferredSpan(int var1);
  121.  
  122.    public int getResizeWeight(int var1) {
  123.       return 0;
  124.    }
  125.  
  126.    public int getStartOffset() {
  127.       return this.elem.getStartOffset();
  128.    }
  129.  
  130.    public View getView(int var1) {
  131.       return null;
  132.    }
  133.  
  134.    public int getViewCount() {
  135.       return 0;
  136.    }
  137.  
  138.    public ViewFactory getViewFactory() {
  139.       View var1 = this.getParent();
  140.       return var1 != null ? var1.getViewFactory() : null;
  141.    }
  142.  
  143.    public void insertUpdate(DocumentEvent var1, Shape var2, ViewFactory var3) {
  144.    }
  145.  
  146.    public boolean isVisible() {
  147.       return true;
  148.    }
  149.  
  150.    /** @deprecated */
  151.    public Shape modelToView(int var1, Shape var2) throws BadLocationException {
  152.       return this.modelToView(var1, var2, Bias.Forward);
  153.    }
  154.  
  155.    public abstract Shape modelToView(int var1, Shape var2, Position.Bias var3) throws BadLocationException;
  156.  
  157.    public Shape modelToView(int var1, Position.Bias var2, int var3, Position.Bias var4, Shape var5) throws BadLocationException {
  158.       Shape var6 = this.modelToView(var1, var5, var2);
  159.       Object var7;
  160.       if (var3 == this.getEndOffset()) {
  161.          try {
  162.             var7 = this.modelToView(var3, var5, var4);
  163.          } catch (BadLocationException var11) {
  164.             var7 = null;
  165.          }
  166.  
  167.          if (var7 == null) {
  168.             Rectangle var8 = var5 instanceof Rectangle ? (Rectangle)var5 : var5.getBounds();
  169.             var7 = new Rectangle(var8.x + var8.width - 1, var8.y, 1, var8.height);
  170.          }
  171.       } else {
  172.          var7 = this.modelToView(var3, var5, var4);
  173.       }
  174.  
  175.       Rectangle var12 = var6.getBounds();
  176.       Rectangle var9 = var7 instanceof Rectangle ? (Rectangle)var7 : ((Shape)var7).getBounds();
  177.       if (var12.y != var9.y) {
  178.          Rectangle var10 = var5 instanceof Rectangle ? (Rectangle)var5 : var5.getBounds();
  179.          var12.x = var10.x;
  180.          var12.width = var10.width;
  181.       }
  182.  
  183.       var12.add(var9);
  184.       return var12;
  185.    }
  186.  
  187.    public abstract void paint(Graphics var1, Shape var2);
  188.  
  189.    public void preferenceChanged(View var1, boolean var2, boolean var3) {
  190.       View var4 = this.getParent();
  191.       if (var4 != null) {
  192.          var4.preferenceChanged(this, var2, var3);
  193.       }
  194.  
  195.    }
  196.  
  197.    public void removeUpdate(DocumentEvent var1, Shape var2, ViewFactory var3) {
  198.    }
  199.  
  200.    public void setParent(View var1) {
  201.       this.parent = var1;
  202.    }
  203.  
  204.    public void setSize(float var1, float var2) {
  205.    }
  206.  
  207.    /** @deprecated */
  208.    public int viewToModel(float var1, float var2, Shape var3) {
  209.       sharedBiasReturn[0] = Bias.Forward;
  210.       return this.viewToModel(var1, var2, var3, sharedBiasReturn);
  211.    }
  212.  
  213.    public abstract int viewToModel(float var1, float var2, Shape var3, Position.Bias[] var4);
  214. }
  215.